import 'package:flutter/material.dart';

/// 横向列表

class HorizontalListApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final String appTitle = 'Horizontal List Demo';
    return MaterialApp(
      title: appTitle,
      theme: ThemeData(primarySwatch: Colors.red),
      home: HorizontalListAppPage(title: appTitle),
    );
  }
}

class HorizontalListAppPage extends StatefulWidget {
  final String title;

  HorizontalListAppPage({Key key, this.title}) : super(key: key);

  @override
  State<StatefulWidget> createState() => HorizontalListAppPageState();
}

class HorizontalListAppPageState extends State<HorizontalListAppPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Container(
        // 对称
        margin: EdgeInsets.symmetric(vertical: 20.0),
        height: 200.0,
        child: ListView(
          scrollDirection: Axis.horizontal,
          children: <Widget>[
            Container(
              width: 160.0,
              color: Colors.red,
            ),
            Container(
              width: 160.0,
              color: Colors.blue,
            ),
            Container(
              width: 160.0,
              color: Colors.green,
            ),
            Container(
              width: 160.0,
              color: Colors.yellow,
            ),
            Container(
              width: 160.0,
              color: Colors.orange,
            ),
          ],
        ),
      ),
    );
  }
}
